﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Collections;
using JXT.PrimaryKey.Batman.Domain.Repositories;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Domain.Quotation.Models;

namespace JXT.PrimaryKey.Batman.Domain.Quotation.Repositories
{
    /// <summary>
    /// 股票代码历史行情存储接口
    /// </summary>
    public interface IMarketStatisticRepository : IReadRepository<MarketStatistic, int>,IWriteRepository<MarketStatistic,int>,
         ISpecificationRepository<MarketStatistic>
    {
        /// <summary>
        /// 根据给出的条件查询单条周行情
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>周行情数据</returns>
        WeekMarketStatistic GetWeekSingle(ISpecification<WeekMarketStatistic> specification);

        /// <summary>
        /// 根据给出的条件查询周行情集合
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>周行情集合</returns>
        IPagedCollection<WeekMarketStatistic> GetWeekList(IPagedSpecification<WeekMarketStatistic> specification);

        /// <summary>
        /// 根据给出的条件查询单条月行情数据
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>月行情数据</returns>
        MonthMarketStatistic GetMonthSingle(ISpecification<MonthMarketStatistic> specification);

        /// <summary>
        /// 根据给出的条件查询月行情数据集合
        /// </summary>
        /// <param name="specification">条件对象</param>
        /// <returns>月行情数据集合</returns>
        IPagedCollection<MonthMarketStatistic> GetMonthList(IPagedSpecification<MonthMarketStatistic> specification);

        MarketStatistic GetLastDayData(string code, MarketType markettype, DateTime dt);

        /// <summary>
        /// 获取上周的记录
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">日期</param>
        /// <returns>得到上周股票相关信息</returns>
        WeekMarketStatistic GetLastWeekDate(string code, MarketType markettype, DateTime dt);

        /// <summary>
        /// 获取上月的记录
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">日期</param>
        /// <returns>上月的股票相关信息</returns>
        MonthMarketStatistic GetLastMonthDate(string code, MarketType markettype, DateTime dt);

        /// <summary>
        /// 根据条件从日数据表中获取周数据
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="markettype">市场类型</param>
        /// <param name="tuple">周的开始时间和结束时间的tuple</param>
        /// <returns>时间范围内的数据的集合</returns>
        IEnumerable<WeekMarketStatistic> GetWeekList(string code, MarketType markettype, Tuple<DateTime, DateTime> tuple);

        /// <summary>
        ///找到单条周数据
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">更新时间</param>
        /// <returns>得到单条周数据</returns>
        WeekMarketStatistic GetWeekSingle(string code, MarketType markettype, DateTime dt);

        /// <summary>
        /// 从日数据中找到月数据
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="markettype">市场类型</param>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        /// <returns>时间范围类的数据的集合</returns>
        IEnumerable<MonthMarketStatistic> GetMonthList(string code, MarketType markettype, DateTime starttime, DateTime endtime);

        /// <summary>
        /// 找到单条的月数据
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">更新时间</param>
        /// <returns>月数据</returns>
        MonthMarketStatistic GetMonthSingle(string code, MarketType markettype, DateTime dt);


        /// <summary>
        /// 根据时间和和市场删除数据
        /// </summary>
        /// <param name="markettype">市场类型</param>
        /// <param name="dt">时间</param>
        void DeleteDayData(MarketType markettype, DateTime dt);
    }
}
